﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SIPO.master" AutoEventWireup="false" 
    CodeFile="rptRecSanction.aspx.cs" Inherits="SIPO.Web.Reports.Transaction.rptRecSanction" %>

<asp:Content ID="ctnBody" ContentPlaceHolderID="body" runat="server">
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.wrapper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery-ui.min.js") %>" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {

            //default radio button semua
            $("#<%= txtPeriodeAwal.ClientID %>").attr('disabled', 'disabled');
            $("#<%= txtPeriodeAkhir.ClientID %>").attr('disabled', 'disabled');
            $("#<%= ddlTipeSanksi.ClientID %>").attr('disabled', 'disabled');
            $("#<%= ddlDebitur.ClientID %>").attr('disabled', 'disabled');

            $("#<%= txtPeriodeAwal.ClientID %>").val('Periode Awal');
            $("#<%= txtPeriodeAkhir.ClientID %>").val('Periode Akhir');
            $("#<%= ddlTipeSanksi.ClientID %>").val('-- Pilih Jenis Sanksi --');
            $("#<%= ddlDebitur.ClientID %>").val('-- Pilih Perusahaan --');



            // format tanggal dengan datepicker
            $("#<%= txtPeriodeAwal.ClientID  %>").datepicker({ showWeek: true, showButtonPanel: true,
                changeMonth: true, changeYear: true, dateFormat: 'dd/mm/yy',
                numberOfMonths: 1,
                onSelect: function (selected) {
                    $("#<%= txtPeriodeAkhir.ClientID %>").datepicker("option", "minDate", selected)
                }
            });

            $("#<%= txtPeriodeAkhir.ClientID  %>").datepicker({ showWeek: true, showButtonPanel: true,
                changeMonth: true, changeYear: true, dateFormat: 'dd/mm/yy',
                numberOfMonths: 1,
                onSelect: function (selected) {
                    $("#<%= txtPeriodeAwal.ClientID %>").datepicker("option", "maxDate", selected)
                }
            });

            //radio button periode awal dan periode akhir
            $("#<%= rbPeriode1.ClientID %>").click(function () {
                $("#<%= txtPeriodeAwal.ClientID %>").removeAttr('disabled');
                $("#<%= txtPeriodeAkhir.ClientID %>").removeAttr('disabled');
                $("#<%= txtPeriodeAwal.ClientID %>").val('');
                $("#<%= txtPeriodeAkhir.ClientID %>").val('');
            });

            $("#<%= rbPeriode3.ClientID %>").click(function () {
                $("#<%= txtPeriodeAwal.ClientID %>").attr('disabled', 'disabled');
                $("#<%= txtPeriodeAkhir.ClientID %>").attr('disabled', 'disabled');
                $("#<%= txtPeriodeAwal.ClientID %>").val('Periode Awal');
                $("#<%= txtPeriodeAkhir.ClientID %>").val('Periode Akhir');
            });

            //radio button sanksi
            $("#<%= rbTipeSanksi1.ClientID %>").click(function () {
                $("#<%= ddlTipeSanksi.ClientID %>").removeAttr('disabled');
            });

            $("#<%= rbTipeSanksi2.ClientID %>").click(function () {
                $("#<%= ddlTipeSanksi.ClientID %>").attr('disabled', 'disabled');
                $("#<%= ddlTipeSanksi.ClientID %>").val('-- Pilih Jenis Sanksi --')
            });

            //radio button perusahaan
            $("#<%= rbDebitur1.ClientID %>").click(function () {
                $("#<%= ddlDebitur.ClientID %>").removeAttr('disabled');
            });

            $("#<%= rbDebitur2.ClientID %>").click(function () {
                $("#<%= ddlDebitur.ClientID %>").attr('disabled', 'disabled');
                $("#<%= ddlDebitur.ClientID %>").val('-- Pilih Perusahaan --')
            });

            $("#btnNext").click(function () {
                OpenForm();
            });

            function OpenForm() {
                var periodeAwal;
                var periodeAkhir;

                if ($("#<%= txtPeriodeAwal.ClientID %>").is(':disabled'))
                    periodeAwal = "";
                else
                    periodeAwal = $("#<%= txtPeriodeAwal.ClientID %>").val();

                if ($("#<%= txtPeriodeAkhir.ClientID %>").is(':disabled'))
                    periodeAkhir = "";
                else
                    periodeAkhir = $("#<%= txtPeriodeAkhir.ClientID %>").val();

                var sanctionTypeID = $("#<%= ddlTipeSanksi.ClientID %>").val();
                var debtorID = $("#<%= ddlDebitur.ClientID %>").val();

                //alert(debtorID);

                var isReview;
                var isApprove;

                if ($("#<%= rbReview1.ClientID %>").is(":checked"))
                    isReview = $("#<%= rbReview1.ClientID %>").val();
                else if ($("#<%= rbReview2.ClientID %>").is(":checked"))
                    isReview = $("#<%= rbReview2.ClientID %>").val();
                else if ($("#<%= rbReview3.ClientID %>").is(":checked"))
                    isReview = $("#<%= rbReview3.ClientID %>").val();


                if ($("#<%= rbApprove1.ClientID %>").is(":checked"))
                    isApprove = $("#<%= rbApprove1.ClientID %>").val();
                else if ($("#<%= rbApprove2.ClientID %>").is(":checked"))
                    isApprove = $("#<%= rbApprove2.ClientID %>").val();
                else if ($("#<%= rbApprove3.ClientID %>").is(":checked"))
                    isApprove = $("#<%= rbApprove3.ClientID %>").val();

                var formUrl = '<%= ResolveUrl("~/reports/rptSanctionViewer.aspx") %>';

                $('#dialog1').load(formUrl + "?periodeAwal=" + periodeAwal + "&periodeAkhir=" + periodeAkhir + "&sanctionTypeID=" + sanctionTypeID + "&debtorID=" + debtorID + "&isReview=" + isReview + "&isApprove=" + isApprove).dialog({ autoOpen: false, modal: true, width: 1200, title: 'Laporan Sanksi' });
                $("#dialog1").dialog('open');
            }

        });
    </script>

    <table border="0">
                <tr>
                    <td style="width: 50">
                        Periode
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:RadioButton ID="rbPeriode1" runat="server" GroupName="rbPeriode" /><asp:TextBox ID="txtPeriodeAwal" runat="server" Width="150"></asp:TextBox> s/d
                        <asp:TextBox ID="txtPeriodeAkhir" runat="server" Width="150"></asp:TextBox>
                    </td>
               </tr>
               <tr>
                <td colspan="2"></td>
                        <td><asp:RadioButton ID="rbPeriode3" runat="server" GroupName="rbPeriode" 
                            Checked="True" Text="Semua" /></td>
                </tr>
                <tr>
                    <td style="width: 50">
                        Jenis Sanksi
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:RadioButton ID="rbTipeSanksi1" runat="server" GroupName="rbTipeSanksi"/>
                        <asp:DropDownList ID="ddlTipeSanksi" runat="server" Width="200">
                        </asp:DropDownList>
                    </td>
               </tr>
               <tr>
                <td colspan="2"></td>
                    <td>
                        <asp:RadioButton ID="rbTipeSanksi2" runat="server" GroupName="rbTipeSanksi" 
                            Checked="True" Text="Semua" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 50">
                        Debitur
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:RadioButton ID="rbDebitur1" runat="server" GroupName="rbDebitur"/>
                        <asp:DropDownList ID="ddlDebitur" runat="server" Width="200">
                        </asp:DropDownList>
                    </td>
              </tr>
              <tr>
                <td colspan="2"></td>
                    <td>
                        <asp:RadioButton ID="rbDebitur2" runat="server" GroupName="rbDebitur" 
                            Checked="True" Text="Semua" />
                    </td>
              </tr>
              <tr>
                    <td style="width: 50">
                        Review
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:RadioButton ID="rbReview1" runat="server" GroupName="rbReview" Text="Belum" value="1"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2"></td>
                    <td>
                        <asp:RadioButton ID="rbReview2" runat="server" GroupName="rbReview" Text="Sudah" value="2"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2"></td>
                    <td>
                        <asp:RadioButton ID="rbReview3" runat="server" GroupName="rbReview" value="3"
                            Checked="True" Text="Semua" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 50">
                       Di Setujui
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:RadioButton ID="rbApprove1" runat="server" GroupName="rbApprove" Text="Belum" value="1"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2"></td>
                    <td>
                        <asp:RadioButton ID="rbApprove2" runat="server" GroupName="rbApprove" Text="Sudah" value="2" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2"></td>
                    <td>
                        <asp:RadioButton ID="rbApprove3" runat="server" GroupName="rbApprove" value="3"
                            Checked="True" Text="Semua" />
                    </td>
                </tr>
                <tr>
            <td colspan="2">
            </td>
            <td>
                <div style="text-align: right; padding-top: 10px;">
                    <button class="dialog_link ui-state-default ui-corner-all" id="btnNext" type="button">Lanjut</button>
                    <button class="dialog_link ui-state-default ui-corner-all" id="btnCancel" type="button">Batal</button>
                </div>
            </td>
        </tr>
      </table>
      <div id="dialog1" title="Default dialog"></div>
 </asp:Content>